<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<head>
    <meta charset="utf-8">
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <meta content="width=device-width, minimum-scale=1,initial-scale=1, maximum-scale=1, user-scalable=1" id="viewport" name="viewport" />
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta content="telephone=no" name="format-detection" />
    <link type="text/css" rel="stylesheet" href="../../template/css/com/com.css" />
    <link type="text/css" rel="stylesheet" href="../../template/css/list/style.css" />
    <link rel="stylesheet" href="../../resource/weuimin.css" />
    <link rel="stylesheet" href="../../resource/jinsuistyle.css" />
    <script src="../../template/js/jquery.js"></script>
    <script type="text/javascript" src="../../script/constants.js"></script>
    <script type="text/javascript" charset="UTF-8" src="../../script/naes.js"></script>
    <script src="../../script/api.js"></script>
    <style type="text/css">
        body {
            background-color: #f1f1f1 !important;
        }
    </style>
    <script type="text/javascript">
        var doubliSplierId = 1;
        window.apiready = function() {

        }

        function sureSearch() {
            var queryTxt = $("#quary_text").val();
            // alert(queryTxt);
              $("#loadingToast").show();
            api.ajax({
                url: 'http://api.map.baidu.com/place/v2/suggestion?query=' + queryTxt + '&region=四川&city_limit=true&output=json&ak=asUbdVtZj9NRifoZkMeTrqzSsGddlCGH',
                method: 'get',
            }, function(ret, err) {
                if (ret) {
                    var data = ret.result;
                    var html="";
                      if(ret.status==0){
                            for (var i = 0; i < data.length; i++) {
                                var name = data[i].name;
                                html +='<div style="height:30px;width:97%;border-bottom:1px solid #AAAAAA;background-color:f1f1f1;font-size:18px;line-height30px;margin:5px" onclick="toDetail(\''+name+'\')" >'+name+' </div>';
                            }
                      }
                      else {
                        html+="未找到相关信息，请修改后重试";
                      }
                      // console.log(html);
                        $('#searchResult').html(html);
                            $("#loadingToast").hide();
                } else {
                    api.alert({
                        msg: JSON.stringify(err)
                    });
                }
            });

        }

        function toDetail(name){
          api.sendEvent({
            name: 'returnSearchDestination',
            extra: {
                name: name,
                // key2: 'value2'
            }
        });
        api.closeWin();
    }
    </script>
</head>
<header id="statusBar">
    <div style="height:75px;background: #298cb4;display: table;width: 100%;">
        <div style="height:50px;margin-top: 25px;line-height: 50px;color: #ffffff;background: #1e6887;">
            <div style="width: 26%;margin-left: 4%;font-size: 16px;float: left;" onclick="api.closeWin();">
                返回
            </div>
            <div style="text-align: center;font-weight:bold;width: 40%;font-size: 16px;float: left;">
                选择目的地
            </div>
        </div>
    </div>
</header>
<div class="com-content" style="padding-top: 0px;background-color:#f1f1f1;position:relativ">
    <div style="width:97%;heigth:50px;border:1px solid #AAAAAA;margin:5px">
        <div style="width:40px;height:36px;background:url('../../image/search_zc/search.png');background-size:100%;margin:5px;float:left;"></div>
        <input id='quary_text' type="text" name="input" style="height:36px;width:222px;margin-left:0px;border:0px" placeholder="搜索目的地" />
        <div style="width:55px;height:40px;background-color:#cccccc;margin:5px;float:right;font-size:18px;line-height:40px;text-align:center" onclick="sureSearch()">确定</div>
    </div>
    <div id="searchResult" style="width:100%;">
        <!-- <div style="height:30px;width:97%;border-bottom:1px solid #AAAAAA;background-color:f1f1f1;font-size:18px;line-height30px;margin:5px" onclick="toDetail(123)">成都 </div> -->
    </div>
</div>
<!-- background:url('../../image/search_zc/location1.jpg')
		</div>
	</div> -->
<!-- 加载动画 -->
<div id="loadingToast" style="display:none;">
    <div class="weui-mask_transparent"></div>
    <div class="weui-toast">
        <i class="weui-loading weui-icon_toast"></i>
        <p class="weui-toast__content">数据加载中...</p>
    </div>
</div>
<!-- 公共底部，必须引用 -->

<!--			<div class="com-footer-area footer" id="js-com-footer" style="width:100%;height: 8%;">
				<img src="../../image/db.png" style="width:100%;"/>
			</div>-->

</body>

</html>
